// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
//导入 (在api/index.js中已经导入)
// import Axios from 'axios'
//导入element
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

import router from './router'

//导入全局样式   @代表src目录在 build的webpack.base.cong.js 文件中定义
import '@/assets/css/index.css'

//激活element
Vue.use(ElementUI);
Vue.config.productionTip = false

//判断用户是否非法访问(监听路由变化,防翻墙)
router.beforeEach((to, from, next) => {
  // 获取token
  var token = localStorage.getItem("mytoken")
  if(to.path !='/login' && !token){
    next({path:'/login'})
  }
    next()
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
